﻿#region Usings

using System.Data.Entity.ModelConfiguration;
using Rail.Net.Core.Model;

#endregion

namespace Rail.Net.Data.Configuration
{
    public class RelationDescriptionMap : EntityTypeConfiguration<RelationDescription>
    {
        public RelationDescriptionMap()
        {
            ToTable("RelationDescriptions");
            HasKey(relationDescription => relationDescription.Id);

            Property(relationDescription => relationDescription.ValidFrom).IsRequired();
            Property(relationDescription => relationDescription.ValidTo).IsRequired();
            Property(relationDescription => relationDescription.StationType).IsRequired();
            Property(relationDescription => relationDescription.Included).IsRequired();

            HasRequired(relationDescription => relationDescription.Station).WithMany(station => station.RelationDescriptions);
            HasRequired(relationDescription => relationDescription.Relation).WithMany(relation => relation.Descriptions);
        }
    }
}